class Solution:
    def addSpaces(self, s: str, spaces: List[int]) -> str:
        spaces.append(len(s))
        return s[:spaces[0]] + ''.join(' ' + s[spaces[i]:spaces[i+1]] for i in range(len(spaces) - 1))
